import unittest
from api.user_withdraw_record_api import userWithdrawRecord
from parameterized import parameterized
from common.read_data import readWithdrawRecordAdd, readQueryWithdrawById, readUpdateWithdraw, \
    read_manage_user_delete_uid, readDeleteWithdraw
from common.assertUtil import assertUtil


class TestWithdrawRecord(unittest.TestCase):
    # 添加提现记录
    @parameterized.expand(readWithdrawRecordAdd())
    def test_add(self, desc, req_data, success, msg):
        resp = userWithdrawRecord.add_Withdraw(req_data)
        assertUtil(self, resp, success, msg)

    # 查询所有提现记录
    def test_query_all(self):
        json_data = {
            "approvalUserId": "",
            "createTimeBegin": "",
            "createTimeEnd": "",
            "id": "",
            "orders": [
                {
                    "asc": True,
                    "column": ""
                }
            ],
            "pageNum": 1,
            "pageSize": 10,
            "searchCount": False,
            "updateTimeBegin": "",
            "updateTimeEnd": "",
            "userId": "",
            "withdrawStatus": ""
        }
        resp = userWithdrawRecord.select_Withdraw(json_data)
        assertUtil(self, resp, True, "操作成功")

    # 通过ID查看详情
    @parameterized.expand(readQueryWithdrawById())
    def test_query_by_id(self, desc, userId, success, expect):
        resp = userWithdrawRecord.select_Withdraw_id(userId)
        assertUtil(self, resp, success, expect)

    # 修改提现记录表
    @parameterized.expand(readUpdateWithdraw())
    def test_update(self,desc,req_data,success,msg):
        resp = userWithdrawRecord.update_Withdraw(req_data)
        assertUtil(self,resp,success,msg)

    # ID删除提现记录
    @parameterized.expand(readDeleteWithdraw())
    def test_delete_id(self,desc,Id,success,expect):
        resp = userWithdrawRecord.delete_Withdraw(Id)
        assertUtil(self,resp,success,expect)